unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, RzStatus, ExtCtrls, RzPanel,Form_View,StdCtrls, DB, ADODB,
  Class_Unit;

type
  TForm_Main = class(TForm)
    MainMenu1: TMainMenu;
    A1: TMenuItem;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    RzStatusBar1: TRzStatusBar;
    RzStatusPane1: TRzStatusPane;
    RzStatusPane2: TRzStatusPane;
    RzStatusPane3: TRzStatusPane;
    RzMarqueeStatus1: TRzMarqueeStatus;
    ABout1: TMenuItem;
    text1: TMenuItem;
    procedure N2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure text1Click(Sender: TObject);
  private
    FStrsView:TStringList;
  public
    procedure AppendView(AView:TFormView;AClassForm: TFormClass);
    procedure RemoveView(AView:TFormView);
  end;

var
  Form_Main: TForm_Main;

implementation
uses
  Form_ListUnit,Form_ListCrew;

{$R *.dfm}

procedure TForm_Main.N2Click(Sender: TObject);
begin
  AppendView(FormListUnit,TFormListUnit);
end;

procedure TForm_Main.FormCreate(Sender: TObject);
begin
  FStrsView:=TStringList.Create;
end;

procedure TForm_Main.AppendView(AView: TFormView; AClassForm: TFormClass);
var
  AIdex:Integer;
begin
  AIdex:=FStrsView.IndexOf(AClassForm.ClassName);
  Writeln(AClassForm.className);
  if AIdex=-1 then
  begin
    AView:=AClassForm.Create(Application) as TFormView;
    Writeln(AView.ClassName);
    FStrsView.AddObject(AView.ClassName,AView);
    AView.Show;
  end else
  begin
    AView:=TFormView(FStrsView.Objects[AIdex]);
    AView.BringToFront;
  end;
end;

procedure TForm_Main.N3Click(Sender: TObject);
begin
  AppendView(FormListCrew,TFormListCrew);
end;

procedure TForm_Main.RemoveView(AView: TFormView);
var
  IdexA:Integer;
begin
  if (FStrsView=nil) or (FStrsView.Count=0) then Exit;
  IdexA:=FStrsView.IndexOf(AView.ClassName);
  if IdexA<>-1 then
  begin
    FStrsView.Delete(IdexA);
  end;
end;



procedure TForm_Main.text1Click(Sender: TObject);
var
  AUnit:TUnit;
  I:Integer;
  StrsA:TStringList;
begin
//  AUnit:=TUnit.Create;
//  AUnit.UnitLink:='0001-0001';
//  AUnit.InsertDB(self.ADOConnection1);
//  StrsA:=TUnit.StrsDB('select * from tbl_unit',self.ADOConnection1);
//  if (StrsA=nil) or (StrsA.Count=0) then Exit;
//  for I:=0 to StrsA.Count-1 do
//  begin
//    AUnit:=TUnit(StrsA.Objects[I]);
//    ShowMessage(AUnit.UnitLink);
//    
//  end;  


end;

end.
